#include "Exception.h"
using namespace userAngel;


Exception::Exception(QString message)
	: _message(message)
{
}


int Exception::errnum() const { return _errno; }
void Exception::setErrnum(int e) { _errno = e; }

QString Exception::type() const { return "Exception"; }
QString Exception::str() const
{
	return "Exception of type " + type()
	        + ((_message.size() > 0) ? (": " + _message) : "");
}


QString Exception::message() const { return _message; }
const char* Exception::what() const throw()
{
	return str().toStdString().c_str();
}


CError::CError(QString context, int error)
	: Exception("Error in " + context + ((errno == 0) ? "" : strerror(error)))
{
}


IllegalArgumentException::IllegalArgumentException(QString argDescription)
	: Exception("Illegal argument - " + argDescription)
{
}

